deploy: Use syncfs() in addition to sync()
authorColin Walters <walters@verbum.org>
Tue, 14 Apr 2015 17:47:08 +0000 (13:47 -0400)
committerColin Walters <walters@verbum.org>
Tue, 21 Apr 2015 01:03:22 +0000 (21:03 -0400)
commitc58a5c0cb3fe441d61670b613a3513dde6851503
tree11979b15658610aae967f3c63491cfa26fb7f8d1
parent6d84321a16ec581269bee947bb6f6fceacc2f0c4
deploy: Use syncfs() in addition to sync()

For some sort of crazy reason, the `sync()` system call doesn't
actually return an error code, even though from what I can tell in the
kernel it wouldn't be terribly hard to add.

Regardless though, it is better for userspace apps to use `syncfs()`
to avoid flushing filesystems unrelated to what they want to sync.  In
the case of OSTree, this does matter - for example you might have a
network mount point backing your database, and we don't want to block
upgrades on syncing it.

This change is safe because we're doing syncfs in *addition* to the
previous global `sync()` (a revision from an earlier patch).

Now because OSTree only touches the `/` mount point which covers the
repository, the deployment roots (including their copy of `/etc`), as
well as `/boot`, we should at some point later be able to drop the
`sync()` call.  Note that on initial system installs we do relabel
`/var` but that shouldn't happen at ostree time - any new directories
are taken care of via `systemd-tmpfiles` on boot.
src/libostree/ostree-sysroot-deploy.c